'use strict';

module.exports = exec;

const Package = require('@lio-cli/package')
const log = require('@lio-cli/log')

const SETTINGS = {
    init: '@lio-cli/init'
}

// lio-cli init --targetPath D:\software\java\workspace\lio-cli --debug test-project --force
function exec() {
    let targetPath = process.env.CLI_TARGET_PATH
    const homePath = process.env.CLI_HOME_PATH
    log.verbose('targetPath', targetPath)
    log.verbose('homePath', homePath)

    const cmdObj = arguments[arguments.length - 1]
    // console.log(cmdObj.force) 如果命令有--force，输出true
    const cmdName = cmdObj.name()
    const packageName = SETTINGS[cmdName]
    const packageVersion = 'latest'

    if (!targetPath) {
        // 生成缓存路径
        targetPath = ''
    }

    const pkg = new Package({
        targetPath,
        packageName,
        packageVersion
    })
    console.log('pkg', pkg.getRootFilePath())
}
